package engine.planner;
import java.util.*;

import compiler.absyn.Predicate;

public class QueryData {
	public List<String> fields;
	public List<String> tables;
	public List<QueryData> subtables;
	public Predicate pred;
	
	public QueryData(List<String> f,List<String> t,List<QueryData> sbt,Predicate p){
		fields = f;tables = t;subtables = sbt;pred = p;
	}
	public Collection<String> fields() {
		return fields;
	}

	public Collection<String> tables() {
		return tables;
	}

	public Predicate pred() {
		return pred;
	}
	
	public String toString() {
		String result = "select ";
		for (String fldname : fields)
			result += fldname + ", ";
		result = result.substring(0, result.length()-2); //remove final comma
		result += " from ";
		for (String tblname : tables)
			result += tblname + ", ";
		result = result.substring(0, result.length()-2); //remove final comma
		String predstring = pred.toString();
		if (!predstring.equals(""))
			result += " where " + predstring;
		return result;
	}
}
